package list;

public class List1 {
    public static void main(String[] args) {
        Node head = new Node(7);
        head.next = new Node(3);
        head.next.next = new Node(8);
        head.next.next.next = new Node(5);
        head.next.next.next.next = new Node(6);

        //遍历节点
        Node n = head; //从头部节点开始访问
        while (n != null) { //只要引用了节点就继续访问节点数据
            System.out.println(n.value); //访问节点中的数据
            n = n.next; //得到n后面的节点，保存到n
        }
    }

    static class Node {
        private int value;
        private Node prev;
        private Node next;

        public Node(int value) {
            this.value = value;
        }
    }
}
